// @ts-ignore
/* eslint-disable */
import { baseRequest, getTenantId } from '@/services';
import { request } from '@umijs/max';

export async function login(params: Login.LoginParams) {
  return request<API.Result>('/api/auth/oauth/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Tenant-Id': getTenantId(),
    },
    params,
  });
}

export async function currentUser(): Promise<{ data: Login.CurrentUser }> {
  // @ts-ignore
  return baseRequest<API.Result>('auth/rbacUser/current');
}

export async function currentRoutes() {
  // @ts-ignore
  return baseRequest<API.Result>('auth/rbacMenu/routes');
}

export async function outLogin() {
  return baseRequest('auth/rbacUser/outLogin');
}

export async function getCaptcha(phone: string) {
  return baseRequest<Login.Captcha>('auth/captcha', { phone });
}

export async function register() {
  return baseRequest<Login.Captcha>('auth/register', {});
}
